<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:ui="http://java.sun.com/jsf/facelets">

<h:head>
	<h:outputStylesheet library="css" name="default.css" target="head" />
	<title>Modifica Pacchetto</title>
</h:head>
<h:body>
	<f:metadata>
		<f:event type="preRenderView" listener="#{editPaccBean.preloadData()}" />
	</f:metadata>
	<p:button value="Indietro"
		outcome="show_pacchetti.xhtml?faces-redirect=true" />

	<p:panel id="create" header="Crea un nuovo pacchetto!">
		<h:form id="form">
			<h:message for="create_update_pack" errorClass="error"
				id="create_update_pack" />

			<h:panelGrid id="conf" columns="2" columnClasses="column"
				cellpadding="5">
				<h:outputText value="Nome Pacchetto: " />
				<p:inplace id="basic">
					<p:inputText value="#{editPaccBean.pacchetto.nome}" id="nname"
						required="true" requiredMessage="You must enter a user ID" />
				</p:inplace>

				<h:outputText value="Descrizione: " />
				<p:inplace id="basic2">
					<p:inputTextarea value="#{editPaccBean.pacchetto.descrizione}"
						required="true" rows="5" cols="50" counter="counter"
						maxlength="200" counterTemplate="{0} caratteri rimanenti."
						autoResize="false" />
				</p:inplace>
				<h:outputText />
				<h:outputText id="counter" style="text-size:9pt; color:#9C9C9C" />

			</h:panelGrid>
			<p:fieldset legend="Hotel">


				<p:dataTable id="hotel" var="hotel"
					value="#{editPaccBean.getAllHotel()}" rowKey="#{hotel.ID}"
					paginator="true" selection="#{editPaccBean.selHotels}" rows="10"
					immediate="true" filteredValue="#{editPaccBean.filteredH}">
					<f:facet name="header">
          		 Seleziona Hotel del Pacchetto
       			 </f:facet>

					<p:column selectionMode="multiple" style="width:2%" />

					<p:column headerText="Nome" filterBy="nome"
						filterMatchMode="contains">
						<h:outputText value="#{hotel.nome}" />

					</p:column>

					<p:column headerText="Località">
						<h:outputText
							value="#{editPaccBean.getLocalità(hotel.localitàID).nome}" />

					</p:column>
				</p:dataTable>

			</p:fieldset>
			<br />


			<p:fieldset legend="Voli">

				<p:dataTable id="volo" var="tratta"
					value="#{editPaccBean.getAllTratte()}" rowKey="#{tratta.ID}"
					selection="#{editPaccBean.selTratte}" immediate="true"
					filteredValue="#{editPaccBean.filteredTratta}">
					<f:facet name="header">
          		 Seleziona i voli del Pacchetto
       			 </f:facet>
					<p:column selectionMode="multiple" style="width:2%" />
					<p:column headerText="Partenza" filterBy="name"
						filterMatchMode="contains">
						<h:outputText
							value="#{editPaccBean.getAeroporto(tratta.daAeroportoID).name}" />

					</p:column>

					<p:column headerText="Arrivo">
						<h:outputText
							value="#{editPaccBean.getAeroporto(tratta.adAeroportoID).name}" />

					</p:column>

					<p:column headerText="Compagnia" filterBy="nome"
						filterMatchMode="contains">
						<h:outputText
							value="#{editPaccBean.getCompagnia(tratta.compagniaID).nome}" />


					</p:column>

				</p:dataTable>

			</p:fieldset>
			<br />

			<p:fieldset legend="Tour" toggleable="true" toggleSpeed="500">
				<p:dataTable id="tour" var="tour"
					value="#{editPaccBean.getAllTour()}" rowKey="#{tour.ID}"
					selection="#{editPaccBean.selTours}" immediate="true">
					<f:facet name="header">
          		 Seleziona un TOUR per il Pacchetto
       			 </f:facet>
					<p:column selectionMode="multiple" style="width:2%" />
					<p:column headerText="Località">
           		#{editPaccBean.getLocalità(tour.localitàID).nome}
       			 </p:column>

					<p:column headerText="Descrizione">
           		#{tour.descrizione}
       			 </p:column>
				</p:dataTable>
			</p:fieldset>

			<br />


			<h:outputText value="Pubblico: " />
			<p:selectBooleanCheckbox value="#{editPaccBean.pacchetto.pubblico}" />





			<h:commandButton value="Submit" action="#{editPaccBean.salvap()}"
				update="create" />
		</h:form>
	</p:panel>
</h:body>
</html>